/**
 * @copyright 2018 indie Semiconductor
 *
 * This file is proprietary to indie Semiconductor.
 * All rights reserved. Reproduction or distribution, in whole
 * or in part, is forbidden except by express written permission
 * of indie Semiconductor.
 *
 * @file sysctrla_sfr.h
 */

#ifndef __SYSCTRLA_SFR_H__
#define __SYSCTRLA_SFR_H__

#include <stdint.h>

/* -------  Start of section using anonymous unions and disabling warnings  ------- */
#if   defined (__CC_ARM)
  #pragma push
  #pragma anon_unions
#elif defined (__ICCARM__)
  #pragma language=extended
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
  #pragma clang diagnostic push
  #pragma clang diagnostic ignored "-Wc11-extensions"
  #pragma clang diagnostic ignored "-Wreserved-id-macro"
#elif defined (__GNUC__)
  /* anonymous unions are enabled by default */
#elif defined (__TMS470__)
  /* anonymous unions are enabled by default */
#elif defined (__TASKING__)
  #pragma warning 586
#elif defined (__CSMC__)
  /* anonymous unions are enabled by default */
#else
  #warning Not supported compiler type
#endif

/**
 * @brief A structure to represent Special Function Registers for SYSCTRLA.
 */
typedef struct {

  uint32_t RETAIN0;                           /*<! Firmware scratch register 0 +0x000 */

  uint32_t RETAIN1;                           /*<! Firmware scratch register 1 +0x004 */

  uint32_t RETAIN2;                           /*<! Firmware scratch register 2 +0x008 */

  uint32_t RETAIN3;                           /*<! Firmware scratch register 3 +0x00C */

  uint32_t DEBUGKEY;                          /* +0x010 */

  uint32_t TRIMKEY;                           /* +0x014 */

  union {
    struct {
      uint8_t  BGTRIM                   :  8; /*!< Band Gap Trim */
      uint8_t  V2ITRIM                  :  8; /*!< V2I Resistor Trim */
      uint16_t                          : 16; /*   (reserved) */
    };
    uint32_t WORD;
  } PMU_TRIM; /* +0x018 */

  uint8_t  TRIM_LF_RC;                        /*<! 10KHz RC oscillator trim +0x01C */
  uint8_t  _RESERVED_1D[3];                   /* +0x01D */

  uint8_t  TRIM_HF_RC;                        /*<! High Frequency RC Oscillator trim +0x020 */
  uint8_t  _RESERVED_21[3];                   /* +0x021 */

  union {
    struct {
      uint8_t  BIAS_SEL                 :  1; /*!< High Voltage LED bias select */
      uint8_t                           :  3; /*   (reserved) */
      uint8_t  BIAS_REG                 :  1; /*!< High Voltage LED bias select register */
      uint8_t                           :  3; /*   (reserved) */
      uint32_t                          : 24; /*   (reserved) */
    };
    uint32_t WORD;
  } LEDBIAS; /* +0x024 */

  union {
    struct {
      uint8_t  TRIM0                    :  4; /*!< High Voltage LED0 trim (trm_iLED) */
      uint8_t  TRIM1                    :  4; /*!< High Voltage LED1 trim (trm_iLED) */
      uint8_t  TRIM2                    :  4; /*!< High Voltage LED2 trim (trm_iLED) */
      uint8_t  TRIM3                    :  4; /*!< High Voltage LED3 trim (trm_iLED) */
      uint8_t  TRIM4                    :  4; /*!< High Voltage LED4 trim (trm_iLED) */
      uint8_t  TRIM5                    :  4; /*!< High Voltage LED5 trim (trm_iLED) */
      uint8_t  TRIM6                    :  4; /*!< High Voltage LED6 trim (trm_iLED) */
      uint8_t  TRIM7                    :  4; /*!< High Voltage LED7 trim (trm_iLED) */
    };
    uint32_t WORD;
  } LEDTRIM07; /* +0x028 */

  union {
    struct {
      uint8_t  TRIM8                    :  4; /*!< High Voltage LED8 trim (trm_iLED) */
      uint8_t  TRIM9                    :  4; /*!< High Voltage LED9 trim (trm_iLED) */
      uint8_t  TRIM10                   :  4; /*!< High Voltage LED10 trim (trm_iLED) */
      uint8_t  TRIM11                   :  4; /*!< High Voltage LED11 trim (trm_iLED) */
      uint8_t  TRIM12                   :  4; /*!< High Voltage LED12 trim (trm_iLED) */
      uint8_t  TRIM13                   :  4; /*!< High Voltage LED13 trim (trm_iLED) */
      uint8_t  TRIM14                   :  4; /*!< High Voltage LED14 trim (trm_iLED) */
      uint8_t  TRIM15                   :  4; /*!< High Voltage LED15 trim (trm_iLED) */
    };
    uint32_t WORD;
  } LEDTRIM815; /* +0x02C */

  union {
    struct {
      uint8_t  TRIM16                   :  4; /*!< High Voltage LED16 trim (trm_iLED) */
      uint8_t  TRIM17                   :  4; /*!< High Voltage LED17 trim (trm_iLED) */
      uint8_t  TRIM18                   :  4; /*!< High Voltage LED18 trim (trm_iLED) */
      uint8_t  TRIM19                   :  4; /*!< High Voltage LED19 trim (trm_iLED) */
      uint8_t  TRIM20                   :  4; /*!< High Voltage LED20 trim (trm_iLED) */
      uint8_t  TRIM21                   :  4; /*!< High Voltage LED21 trim (trm_iLED) */
      uint8_t  TRIM22                   :  4; /*!< High Voltage LED22 trim (trm_iLED) */
      uint8_t  TRIM23                   :  4; /*!< High Voltage LED23 trim (trm_iLED) */
    };
    uint32_t WORD;
  } LEDTRIM1623; /* +0x030 */

  union {
    struct {
      uint8_t  TXSLEW1                  :  2; /*!< LIN1 Transmitter Slew Select */
      uint8_t                           :  2; /*   (reserved) */
      uint8_t  TXIPD1                   :  2; /*!< LIN1 Transmitter Pulldown Strength */
      uint8_t                           :  2; /*   (reserved) */
      uint8_t  TXSLEW2                  :  2; /*!< LIN2 Transmitter Slew Select */
      uint8_t                           :  2; /*   (reserved) */
      uint8_t  TXIPD2                   :  2; /*!< LIN2 Transmitter Pulldown Strength */
      uint8_t                           :  2; /*   (reserved) */
      uint16_t                          : 16; /*   (reserved) */
    };
    uint32_t WORD;
  } LIN; /* +0x034 */

  uint8_t  DFTCODE;                           /* +0x038 */
  uint8_t  _RESERVED_39[3];                   /* +0x039 */

  uint8_t  DFTSTS;                            /* +0x03C */
  uint8_t  _RESERVED_3D[3];                   /* +0x03D */

  uint32_t NAME;                              /*<! ASIC name +0x040 */

  uint16_t REV;                               /*<! Silicon Revision +0x044 */
  uint8_t  _RESERVED_46[2];                   /* +0x046 */

  uint8_t  ENABORTESTMODE;                    /*<! BOR Testmode Enable +0x048 */
  uint8_t  _RESERVED_49[3];                   /* +0x049 */

  uint8_t  SPAREBYTE;                         /*<! SPARE BYTE +0x04C */
  uint8_t  _RESERVED_4D[3];                   /* +0x04D */

} SYSCTRLA_SFRS_t;

/* --------  End of section using anonymous unions and disabling warnings  -------- */
#if   defined (__CC_ARM)
  #pragma pop
#elif defined (__ICCARM__)
  /* leave anonymous unions enabled */
#elif (__ARMCC_VERSION >= 6010050)
  #pragma clang diagnostic pop
#elif defined (__GNUC__)
  /* anonymous unions are enabled by default */
#elif defined (__TMS470__)
  /* anonymous unions are enabled by default */
#elif defined (__TASKING__)
  #pragma warning restore
#elif defined (__CSMC__)
  /* anonymous unions are enabled by default */
#else
  #warning Not supported compiler type
#endif

/**
 * @brief The starting address of SYSCTRLA SFRS.
 */
#define SYSCTRLA_SFRS ((__IO SYSCTRLA_SFRS_t *)0x50013000)

#endif /* end of __SYSCTRLA_SFR_H__ section */


